<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ include file="/WEB-INF/view/include/inc.jsp"%>
<!DOCTYPE html >
<html>
<head>
<%@ include file="/WEB-INF/view/include/jQgrid.jsp"%>

</head>
<body style="background-color: white;" class="gray-bg">
	<div class="ibox-content">
		<form class="form-horizontal m-t" id="signupForm">
			<c:if test="${fatherId ==null }">
				<input type="hidden" name="level" value="1" />
			</c:if>
			<c:if test="${fatherId !=null }">
				<input type="hidden" name="level" value="${level }" />
				<input type="hidden" name="fatherId" value="${fatherId }" />
			</c:if>
			<div class="form-group">
				<label class="col-sm-3 control-label">区域名称：</label>
				<div class="col-sm-8">
					<input id="title" name="title" class="form-control" type="text">
				</div>
			</div>
			<c:if test="${fatherId ==null }">
				<div class="form-group">
					<label class="col-sm-3 control-label">所属父级：</label>
					<div class="col-sm-8">
						<select name="fatherId" class="form-control">
							<option value="0">省级、直辖区</option>
						</select>
					</div>
				</div>
			</c:if>
			<div class="form-group">
				<label class="col-sm-3 control-label">说明：</label>
				<div class="col-sm-8">
					<input id="remark" name="remark" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">
				<div class="col-sm-8 col-sm-offset-3">
					<button class="btn btn-primary" type="button" id="submit">提交</button>
				</div>
			</div>
		</form>
	</div>


	<script>
	$(function(){
		$("#submit").click(function(){
			var name = $("#title").val();
			if(name.length==0){
				$("#title").tips({
					side:3,
		            msg:'区域不能为空！',
		            bg:'#AE81FF',
		            time:1
		        });
				$("#title").focus();
				return;
			}
			$("#signupForm").ajaxSubmit({
	        	url:'<%=contextPath %>/area/add',
					type : "post",
					dataType : "json",
					success : function(data) {
						if (data.code == 200) {
							swal({
								title : data.message,
								type : "success",
								showCancelButton : false,
								confirmButtonText : "确定",
								animation : "slide-from-bottom",
								closeOnConfirm : true
							}, function() {
								top.Dialog.close();
							});
						} else {
							swal("错误", data.message, "error");
						}
					}
				});
			});
		});
	</script>
</body>
</html>